package com.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.entity.Message;
import com.entity.Message_set;
import com.entity.Shop;

@Repository("messageMapper")
public interface MessageDao {
	@Select("select * from message_set where user_id=#{u_id}")
	public List<Message_set> m_slist(@Param("u_id")Integer u_id);
	@Select("select count(*) from message_set where shop_id=#{s_id}")
	int shopid (@Param("s_id")Integer s_id);
	@Select("select shop_id from where user_id=#{u_id}")
	public List<Integer> m_shops (@Param("u_id") Integer u_id);
	@Select("select * from message where user_id=#{u_id} and shop_id=#{s_id}")
	public List<Message> all_Messages(@Param("u_id")Integer u_id,@Param("s_id") Integer s_id);
	@Insert("insert into message values(null,#{user_id},#{content},#{date},#{shop_id},#{state})")
	public int sendmessage(Message message);
	@Insert("insert into message_set values(null,#{user_id},#{shop_id},#{first_content},#{image},#{u_name})")
	public int createmessage(Message_set message_set);
	@Update("UPDATE message_set SET first_content = #{first_content} WHERE user_id = #{userid} and shop_id=#{shop_id}")
	public int updatemessage(@Param("first_content")String first_content,@Param("userid")Integer userid,@Param("shop_id") Integer shop_id);
}
